\doxysection{my\+\_\+balence\+\_\+binary\+\_\+tree\texorpdfstring{$<$}{<} T \texorpdfstring{$>$}{>} Class Template Reference}
\hypertarget{classmy__balence__binary__tree}{}\label{classmy__balence__binary__tree}\index{my\_balence\_binary\_tree$<$ T $>$@{my\_balence\_binary\_tree$<$ T $>$}}


平衡二叉树类（模板类，支持任意数据类型\+T）  




{\ttfamily \#include $<$my\+\_\+binary\+\_\+tree.\+h$>$}



Inheritance diagram for my\+\_\+balence\+\_\+binary\+\_\+tree\texorpdfstring{$<$}{<} T \texorpdfstring{$>$}{>}\+:
% FIG 0


Collaboration diagram for my\+\_\+balence\+\_\+binary\+\_\+tree\texorpdfstring{$<$}{<} T \texorpdfstring{$>$}{>}\+:
% FIG 1
\doxysubsubsection*{Public Member Functions}
\begin{DoxyCompactItemize}
\item 
\Hypertarget{classmy__balence__binary__tree_aa7c980d67e7e896e8da7040a2e6b4207}\label{classmy__balence__binary__tree_aa7c980d67e7e896e8da7040a2e6b4207} 
{\bfseries my\+\_\+balence\+\_\+binary\+\_\+tree} (T val)
\end{DoxyCompactItemize}
\doxysubsection*{Public Member Functions inherited from \mbox{\hyperlink{classmy__binary__tree}{my\+\_\+binary\+\_\+tree$<$ T $>$}}}
\begin{DoxyCompactItemize}
\item 
\mbox{\hyperlink{classmy__binary__tree_ae19ca02504d47a17836f0b0c533f8982}{my\+\_\+binary\+\_\+tree}} (T val)
\begin{DoxyCompactList}\small\item\em 构造函数（创建单个节点） \end{DoxyCompactList}\item 
\mbox{\hyperlink{classmy__binary__tree_a6faf690077dab82f4d1f72920c3834fd}{my\+\_\+binary\+\_\+tree}} (const \mbox{\hyperlink{classmy__binary__tree}{my\+\_\+binary\+\_\+tree}}$<$ T $>$ \&other)
\begin{DoxyCompactList}\small\item\em 拷贝构造函数（深拷贝） \end{DoxyCompactList}\item 
\mbox{\hyperlink{classmy__binary__tree_aabd378c4f70ed8c8e76691769d111c59}{\texorpdfstring{$\sim$}{\string~}my\+\_\+binary\+\_\+tree}} ()
\begin{DoxyCompactList}\small\item\em 析构函数（递归释放内存） \end{DoxyCompactList}\item 
\mbox{\hyperlink{classmy__binary__tree}{my\+\_\+binary\+\_\+tree}}$<$ T $>$ \texorpdfstring{$\ast$}{*} \mbox{\hyperlink{classmy__binary__tree_a488bf2adcd7de91b9e259f6ef8c7762b}{construct\+\_\+binary\+\_\+tree}} (vector$<$ T $>$ values, int index, T space)
\begin{DoxyCompactList}\small\item\em 层先法构造普通二叉树（支持空节点） \end{DoxyCompactList}\item 
void \mbox{\hyperlink{classmy__binary__tree_a6f45e4cb6774b092b40bee77ee80b757}{mirror}} ()
\begin{DoxyCompactList}\small\item\em 二叉树镜像（交换所有节点的左右子树） \end{DoxyCompactList}\item 
bool \mbox{\hyperlink{classmy__binary__tree_a8fc393aceaa7e46fc5fb6b9377c12ea3}{is\+\_\+empty}} ()
\begin{DoxyCompactList}\small\item\em 判断二叉树是否为空 \end{DoxyCompactList}\item 
T \mbox{\hyperlink{classmy__binary__tree_a05b6069959ff87dc7824ce4e05db024a}{get\+\_\+value}} ()
\begin{DoxyCompactList}\small\item\em 打印当前节点的数据值 \end{DoxyCompactList}\item 
T \mbox{\hyperlink{classmy__binary__tree_ace03005196f04451f9af5c2ab663a990}{get\+\_\+value}} (string position)
\begin{DoxyCompactList}\small\item\em 打印当前节点的数据值 \end{DoxyCompactList}\item 
int \mbox{\hyperlink{classmy__binary__tree_a047c1a5b1fb76a0cb62700eb1c53bb8b}{get\+\_\+height}} ()
\begin{DoxyCompactList}\small\item\em 计算二叉树的高度 \end{DoxyCompactList}\item 
int \mbox{\hyperlink{classmy__binary__tree_ad8ae3e1b3073a79df62de135e337192a}{get\+\_\+h\+\_\+layer\+\_\+nodes}} (int h)
\begin{DoxyCompactList}\small\item\em 计算第h层的节点总数 \end{DoxyCompactList}\item 
int \mbox{\hyperlink{classmy__binary__tree_a76f83530b098d7ad84262d21c885c15d}{get\+\_\+last\+\_\+layer\+\_\+nodes}} ()
\begin{DoxyCompactList}\small\item\em 计算最后一层（叶子节点层）的节点总数 \end{DoxyCompactList}\item 
int \mbox{\hyperlink{classmy__binary__tree_aabf0c965e92e633f4d25f9b88da19a28}{get\+\_\+nodes\+\_\+num}} ()
\begin{DoxyCompactList}\small\item\em 计算二叉树的总节点数 \end{DoxyCompactList}\item 
\mbox{\hyperlink{classmy__binary__tree}{my\+\_\+binary\+\_\+tree}}$<$ T $>$ \texorpdfstring{$\ast$}{*} \mbox{\hyperlink{classmy__binary__tree_a9279b204f13b6f6e79646fe38387607a}{get\+\_\+lrest\+\_\+leave}} (string l\+\_\+or\+\_\+r)
\begin{DoxyCompactList}\small\item\em 获取最左或最右的叶子节点 \end{DoxyCompactList}\item 
bool \mbox{\hyperlink{classmy__binary__tree_adb685df412bb6481f5167165312868ad}{is\+\_\+binary\+\_\+search\+\_\+tree}} ()
\begin{DoxyCompactList}\small\item\em 判断二叉树是否为二叉搜索树（\+BST） \end{DoxyCompactList}\item 
\mbox{\hyperlink{classmy__binary__tree}{my\+\_\+binary\+\_\+tree}}$<$ T $>$ \texorpdfstring{$\ast$}{*} \mbox{\hyperlink{classmy__binary__tree_a490bf7f8ebe87b6040b1294f73979fea}{find}} (int val)
\begin{DoxyCompactList}\small\item\em 查找值为val的节点 \end{DoxyCompactList}\item 
\mbox{\hyperlink{classmy__binary__tree}{my\+\_\+binary\+\_\+tree}}$<$ T $>$ \texorpdfstring{$\ast$}{*} \mbox{\hyperlink{classmy__binary__tree_ad767eada19d83ada460c5eb0c2104056}{find\+\_\+father}} (\mbox{\hyperlink{classmy__binary__tree}{my\+\_\+binary\+\_\+tree}}$<$ T $>$ \texorpdfstring{$\ast$}{*}son)
\begin{DoxyCompactList}\small\item\em 查找指定节点的父节点 \end{DoxyCompactList}\item 
bool \mbox{\hyperlink{classmy__binary__tree_a35c9081b6b3dfe457c8d29697ccfdfb1}{is\+\_\+balence\+\_\+binary\+\_\+tree}} ()
\begin{DoxyCompactList}\small\item\em 判断二叉树是否为平衡二叉树（左右子树高度差不超过1） \end{DoxyCompactList}\item 
void \mbox{\hyperlink{classmy__binary__tree_aa23b0dbc0a4f4f7741111867f6d8b2e9}{append}} (\mbox{\hyperlink{classmy__binary__tree}{my\+\_\+binary\+\_\+tree}}$<$ T $>$ \texorpdfstring{$\ast$}{*}another\+\_\+tree, string l\+\_\+or\+\_\+r)
\begin{DoxyCompactList}\small\item\em 向当前节点追加左/右子树 \end{DoxyCompactList}\item 
void \mbox{\hyperlink{classmy__binary__tree_a19f020b91ef749755745ac08d69be0b6}{copy}} (\mbox{\hyperlink{classmy__binary__tree}{my\+\_\+binary\+\_\+tree}}$<$ T $>$ \texorpdfstring{$\ast$}{*}des, \mbox{\hyperlink{classmy__binary__tree}{my\+\_\+binary\+\_\+tree}}$<$ T $>$ \texorpdfstring{$\ast$}{*}src)
\begin{DoxyCompactList}\small\item\em 复制二叉树（从src拷贝到des） \end{DoxyCompactList}\item 
void \mbox{\hyperlink{classmy__binary__tree_a9675071237ce43751138c4fa3ef43657}{insert}} (T val, string position)
\begin{DoxyCompactList}\small\item\em 插入节点（未实现） \end{DoxyCompactList}\item 
void \mbox{\hyperlink{classmy__binary__tree_a24a14198a85ebfd603f5284ef9940e41}{delete\+\_\+point}} (\mbox{\hyperlink{classmy__binary__tree}{my\+\_\+binary\+\_\+tree}}$<$ T $>$ \texorpdfstring{$\ast$}{*}point)
\begin{DoxyCompactList}\small\item\em 删除节点（未实现） \end{DoxyCompactList}\item 
void \mbox{\hyperlink{classmy__binary__tree_a5fe4fbbeb0729ef67cc258d2a5350860}{delete\+\_\+pos}} (string position)
\begin{DoxyCompactList}\small\item\em 删除节点（未实现） \end{DoxyCompactList}\item 
\mbox{\hyperlink{classmy__binary__tree}{my\+\_\+binary\+\_\+tree}}$<$ T $>$ \texorpdfstring{$\ast$}{*} \mbox{\hyperlink{classmy__binary__tree_a5842011f1564adb291d8a62f1f7e7625}{revolve}} (string mode)
\begin{DoxyCompactList}\small\item\em 旋转二叉树（未实现） \end{DoxyCompactList}\item 
\mbox{\hyperlink{classmy__binary__tree}{my\+\_\+binary\+\_\+tree}}$<$ T $>$ \texorpdfstring{$\ast$}{*} \mbox{\hyperlink{classmy__binary__tree_abf00c3450fd579d439c231202d2af556}{revolve}} (\mbox{\hyperlink{classmy__binary__tree}{my\+\_\+binary\+\_\+tree}}$<$ T $>$ \texorpdfstring{$\ast$}{*}node, string mode)
\begin{DoxyCompactList}\small\item\em 旋转二叉树（未实现） \end{DoxyCompactList}\item 
void \mbox{\hyperlink{classmy__binary__tree_a3b473ee42358d2ecda1958b1b72fd1dd}{show\+\_\+binary\+\_\+tree}} (string mode)
\begin{DoxyCompactList}\small\item\em 遍历二叉树并打印节点值 \end{DoxyCompactList}\item 
{\footnotesize template$<$typename Function$>$ }\\Function \mbox{\hyperlink{classmy__binary__tree_a4a4f092d8f75d1f8840db3c3b4b6f36e}{traversal\+\_\+binary\+\_\+tree}} (string mode, Function F)
\begin{DoxyCompactList}\small\item\em 遍历二叉树并执行自定义函数（无空节点处理） \end{DoxyCompactList}\item 
{\footnotesize template$<$typename Function1, typename Function2$>$ }\\Function1 \mbox{\hyperlink{classmy__binary__tree_ad3840bd8912df340bc10aa59bc89d1bd}{traversal\+\_\+binary\+\_\+tree}} (string mode, Function1 F1, Function2 F2)
\begin{DoxyCompactList}\small\item\em 遍历二叉树并执行自定义函数（含空节点处理） \end{DoxyCompactList}\item 
void \mbox{\hyperlink{classmy__binary__tree_aff9c3c138c4fc970016a826ec0653eaf}{print\+\_\+full\+\_\+to\+\_\+vector}} (vector$<$ T $>$ \&vv)
\begin{DoxyCompactList}\small\item\em 层序遍历二叉树，将节点值存入向量（不含占位符） \end{DoxyCompactList}\item 
void \mbox{\hyperlink{classmy__binary__tree_aa65e9e0bae93b835e20c32de429928d3}{print\+\_\+to\+\_\+vector}} (vector$<$ T $>$ \&vv)
\begin{DoxyCompactList}\small\item\em 层序遍历二叉树，将节点值存入向量（空节点用占位符） \end{DoxyCompactList}\item 
\mbox{\hyperlink{classmy__binary__tree}{my\+\_\+binary\+\_\+tree}}$<$ T $>$ \& \mbox{\hyperlink{classmy__binary__tree_aedeb2af1e014d361fb7c2f1423e9f58d}{operator=}} (\mbox{\hyperlink{classmy__binary__tree}{my\+\_\+binary\+\_\+tree}}$<$ T $>$ \&other)
\begin{DoxyCompactList}\small\item\em 赋值运算符重载（深拷贝） \end{DoxyCompactList}\item 
T \mbox{\hyperlink{classmy__binary__tree_a52db051eb0ccae70e61baf638acd2f81}{operator\mbox{[}$\,$\mbox{]}}} (int index)
\begin{DoxyCompactList}\small\item\em 索引运算符重载 \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsubsection*{Additional Inherited Members}
\doxysubsection*{Protected Attributes inherited from \mbox{\hyperlink{classmy__binary__tree}{my\+\_\+binary\+\_\+tree$<$ T $>$}}}
\begin{DoxyCompactItemize}
\item 
T {\bfseries data}
\begin{DoxyCompactList}\small\item\em 节点存储的数据 \end{DoxyCompactList}\item 
\mbox{\hyperlink{classmy__binary__tree}{my\+\_\+binary\+\_\+tree}}$<$ T $>$ \texorpdfstring{$\ast$}{*} {\bfseries left}
\begin{DoxyCompactList}\small\item\em 左子树指针 \end{DoxyCompactList}\item 
\mbox{\hyperlink{classmy__binary__tree}{my\+\_\+binary\+\_\+tree}}$<$ T $>$ \texorpdfstring{$\ast$}{*} {\bfseries right}
\begin{DoxyCompactList}\small\item\em 右子树指针 \end{DoxyCompactList}\end{DoxyCompactItemize}


\doxysubsection{Detailed Description}
\subsubsection*{template$<$typename T$>$\newline
class my\+\_\+balence\+\_\+binary\+\_\+tree$<$ T $>$}
平衡二叉树类（模板类，支持任意数据类型\+T） 


\begin{DoxyTemplParams}{Template Parameters}
{\em T} & 二叉树节点存储的数据类型 \\
\hline
\end{DoxyTemplParams}
\begin{DoxyNote}{Note}
支持二叉树的构建、遍历、查询、修改等操作，包含常见的二叉树算法实现 
\end{DoxyNote}


The documentation for this class was generated from the following file\+:\begin{DoxyCompactItemize}
\item 
my\+\_\+binary\+\_\+tree.\+h\end{DoxyCompactItemize}
